package 周赛;

public class 统计按位或能得到最大子集的数目 {
    int max,count;
    public int countMaxOrSubsets(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            //找到按位或的最大值
            max = max | nums[i];
        }
        dfs(nums,0,0);
        return count;
    }

    private void dfs(int[] nums, int index, int num) {
         if (num==max)
             count++;
        for (int i = index; i < nums.length; i++) {
            dfs(nums,i+1, num | nums[i]);
        }
    }
}
